<template>
	<div class="icons">
		<swiper>
			<swiper-slide v-for="(page,index) of pages" :key="index">
				<div class="icon" v-for="item of page" :key="item.id">
					<div class="icon-img">
						<img class="icon-img-content" :src="item.imgurl" alt="">
					</div>
					<p class="icon-desc">{{item.desc}}</p>
				</div>
			</swiper-slide>
			
		</swiper>
	</div>
</template>

<script>
export default{
	name:"homeIcons",
	data (){
		return{
			iconsList:[{
				id:'0001',
				imgurl:"//s.qunarzz.com/homenode/images/touchheader/innBnb.png",
				desc:'民宿客栈',
			},{
				id:'0002',
				imgurl:"//s.qunarzz.com/homenode/images/touchheader/bargainflight.png",
				desc:'低价机票',
			},{
				id:'0003',
				imgurl:"//s.qunarzz.com/homenode/images/touchheader/group.png",
				desc:'特惠酒店',
			},{
				id:'0004',
				imgurl:"//s.qunarzz.com/homenode/images/touchheader/haiwai.png",
				desc:'海外酒店',
			},{
				id:'0005',
				imgurl:"//picbed.qunarzz.com/7804b43ac02cd0333bd0f866eebd43b3.png",
				desc:'一日游',
			},{
				id:'0006',
				imgurl:"//s.qunarzz.com/homenode/images/touchheader/bus.png",
				desc:'汽车船票',
			},{
				id:'0007',
				imgurl:"//s.qunarzz.com/homenode/images/touchheader/tuan.png",
				desc:'团购优惠',
			},{
				id:'0008',
				imgurl:"//s.qunarzz.com/homenode/images/touchheader/freeTravel.png",
				desc:'自由出行',
			},{
				id:'0009',
				imgurl:"//s.qunarzz.com/homenode/images/touchheader/car.png",
				desc:'自驾专驾',
			}],
		}
	},
	computed:{
		pages() {
			const pages = [];
			this.iconsList.forEach((item,index) => {
				const page = Math.floor(index / 8);
				if(!pages[page]){
					pages[page] = [];
				}
				pages[page].push(item);
			})
			return pages
		}
	},
}
</script>

<style lang="stylus" scoped>
@import "../../../assets/css/variables.styl"
	.icons >>> .swiper-container
		overflow hidden
		height 0
		padding-bottom 50%
	.icons
		margin-top .1rem
		.icon
			float left
			width 25%
			height 0
			padding-bottom 25%
			// background-color #42B983
			overflow hidden
			position relative
			.icon-img
				position absolute
				top 0
				bottom .44rem
				left 0
				right 0
				// background blue
				box-sizing border-box
				padding 0.1rem
				.icon-img-content
					height 100%
					display block
					margin 0 auto
			.icon-desc
				bottom 0
				left 0
				right 0
				position absolute
				right .44rem
				line-height .44rem
				color $darkTextColor
				text-align center
				width 100%
</style>
